import logging
import typing


def getLogger(cfg):

    log = logging.getLogger(cfg.mode)
    log.setLevel(logging.INFO)
    if not log.hasHandlers():
        fh = logging.FileHandler(cfg.logf)
        fh.setLevel(logging.INFO)
        console = logging.StreamHandler()
        console.setLevel(logging.INFO)
        formatter = logging.Formatter('%(message)s')
        console.setFormatter(formatter)
        fh.setFormatter(formatter)
        log.addHandler(console)
        log.addHandler(fh)
        if cfg.debug:
            print(f'Register Handlers {log}: LogFile/Console')
    else:
        if cfg.debug:
            print('Skip register handlers')

    return log
